/*
 * Class Organ.java
 * 9.06.2012
 * 
 * Abstract class which represents basic characteristics of 
 * human organ (like organ health).
 */

package human;

/**
 * Basic class of human organ. It has only common for all organs characteristics
 * and methods.
 * 
 * @author Vasyl Khyzhniak
 * @version 1.2
 */
public abstract class Organ {
        protected String name;
	protected int health; // from -100(death) to +100(newborn)
	protected boolean isNecessaryForLife; // is the organ necessary for being
											// alive
        protected OrganParameters parametrs=new OrganParameters();
	public static final int UPPER_LIMIT = 100; // upper limit of organ
												// characteristics
	public static final int LOWER_LIMIT = -100; // lower limit of organ
												// characteristics

	/**
	 * Changes health level on value
	 * 
	 * @param value
	 *            Defines the the change of health
	 */
        
        
        
	public void changeHealth(int value) {
		health = checkLimits(health, value);
	}

	public int getHealth() {
		return health;
	}
        public String getName() {
            return name;
        }

	/**
	 * Returns value which indicates can human live without this organ or no.
	 * There is no "set" method because this parameter could not be changed.
	 * 
	 * @return true if organ is necessary for being alive
	 */
	public boolean getLifeImportance() {
		return isNecessaryForLife;
	}

	/**
	 * @param parameter
	 *            defines which parameter should be checked
	 * @param value
	 *            defines the change of parameter
	 * @return New value for parameter
	 */
	protected int checkLimits(int parameter, int value) {
		if (parameter + value > UPPER_LIMIT) {
			return UPPER_LIMIT;
		} else if (parameter + value < LOWER_LIMIT) {
			return LOWER_LIMIT;
		} else {
			return parameter + value;
		}
	}
        
        public OrganParameters getParametrs() {
            return parametrs;
        }
}
